package com.office.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author shkstart
 * @create 2022-09-28 21:59
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").  //表示文件路径，这里的意思是项目包下的所有文件
                addResourceLocations("/"). //表示要开放的资源
                addResourceLocations("classpath:/resources/").
                addResourceLocations("classpath:/templates/").
                addResourceLocations("classpath:/public/").
                addResourceLocations("/img/").
                addResourceLocations("/images/").
                addResourceLocations("/js/").
                addResourceLocations("/css/").
                addResourceLocations("doc.html").
                addResourceLocations("/webjars/**").
                addResourceLocations("/swagger-resources").
                addResourceLocations("/v2/api-docs")
                .addResourceLocations("/swagger-resources/**")
                .addResourceLocations("/swagger-ui.html/**")
                .addResourceLocations("/webjars/**")
                .addResourceLocations(
                "classpath:/static/");
        registry.addResourceHandler("swagger-ui.html", "doc.html").addResourceLocations(
                "classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/");

        WebMvcConfigurer.super.addResourceHandlers(registry);

    }


    /**
     * 控制器配置
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry)
    {
        registry.addViewController("/").setViewName("/login");
//        registry.addViewController("/login").setViewName("/login.html");
    }


}
